import os
import cv2
import numpy as np


def img_project(
    H: np.ndarray,
    *,
    postfix: str = "",
    bg_path: str = "../bg_img",
    output_dir: str = "../output",
):
    img = cv2.imread(os.path.join(bg_path, f"background{postfix}.png"))
    print(f"H:{H}")
    img_proj = cv2.warpPerspective(img, H, [img.shape[1], img.shape[0]])
    cv2.imwrite(os.path.join(output_dir, f"img_project{postfix}.png"), img_proj)


if __name__ == "__main__":
    H = np.array([[0.8, 0.2, 0], [0, 1 / 0.8, 0], [0.0001, 0.0001, 1]])
    img_project(H, postfix="_snr_-2.145")
